package com.ruihu.admin.constant;

import com.google.common.collect.ImmutableSet;
import org.apache.commons.collections4.CollectionUtils;

import java.util.Set;

/**
 *
 * [ 通用常量 ]
 *
 * @version 1.0
 * @since JDK1.8
 * @author yandanyang
 * @company Ruihu (Nanjing) Information Technology Co., Ltd
 * @copyright (c) 2019 Ruihu (Nanjing) Information Technology Co., LtdInc. All rights reserved.
 * @date
 */
public class CommonConst {

    /**
     * 默认的乐观锁并发版本号
     */
    public static int DEFAULT_OPTI_LOCK_REVISION = 0;

    /**
     * 中国时区
     */
    public static String ZONE_OF_CHINA = "Asia/Shanghai";

    /**
     * Redis 电芯编码集合
     */
    public static String REDIS_ELECTRIC_CORE_CODE_SET_NAME = "electric_core_code";

    /**
     * 缩略前缀
     */
    public final static String THUMBNAIL_PREFIX = "thumb-";

    /**
     * 描述文件
     */
    public final static String DESC_FILE_NAME = "desc.txt";


    public static final class TaskNode {
        public static final  String TASK_NODE_6 = "极组极片检查";
    }


    public static final class Page {
        public static final Integer SIZE = 10;
    }

    public static final class Password {
        public static final String DEFAULT = "123456";
        public static final String SALT_FORMAT = "smart_%s_admin";
    }

    public static final String IGNORE_H5_URL_MAPPING = "/h5/api";

    public static final class CommonCollection {
        public static final Set<String> IGNORE_URL = ImmutableSet.of("/swagger", "Excel");

        public static final Set<String> IGNORE_URL_MAPPING = ImmutableSet.of(IGNORE_H5_URL_MAPPING);

        public static Boolean contain(Set<String> ignores, String uri) {
            if (CollectionUtils.isEmpty(ignores)) {
                return false;
            }
            for (String ignoreUrl : ignores) {
                if (uri.startsWith(ignoreUrl)) {
                    return true;
                }
            }
            return false;
        }
    }

    public static final class Log {

        /**
         * 日志TraceID
         */
        public static final String TRACE_ID = "traceId";
    }

    public static final class Number {

        /**
         * 百分之百
         */
        public static final String ONE_HUNDRED_PERCENT = "100%";

        /**
         * 百分之零
         */
        public static final String ZERO_PERCENT = "0%";
    }

}
